import Decimal from "decimal.js";
export const add = function(numbers = [], decimalPlace = 3) {
	if (!numbers.length) return 0;
	const result = numbers.reduce((sum, number) => new Decimal(sum).add(new Decimal(number)), 0);
	return parseFloat((result).toFixed(decimalPlace));
}

export const subtract = function(numbers = [], decimalPlace = 3) {
	if (!numbers.length) return 0;
	let result = numbers[0] || 0;
	for (let i = 1; i < numbers.length; i++) {
		result = new Decimal(result).sub(new Decimal(numbers[i] || 0));
	}
	return parseFloat((result).toFixed(decimalPlace));
}
